home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 2207 / 2207.xpi / chrome / cooliris.jar / content / cooliris / coolirisSearchBar.js < prev    next >
Text File  |  2010-01-28  |  5KB  |  155 lines

  1. var cpvw_subSearchBar={contextIconTimer:null,parentDoc:null,isShowingIcon:false,selectedText:"",siteSelectedText:"",posX:null,posY:null,toDisplaySearchBar:true,handleEvent:function(_1){
  2. var _2=cpvw_prefHandler.getPref(cpvw_Prefs.prefSubsearchBar);
  3. if(!_2){
  4. return;
  5. }
  6. if(_1.type=="mouseup"){
  7. if(this.getSelection()!=""){
  8. this.showSearchBar();
  9. }
  10. }
  11. },showSearchBar:function(){
  12. var _3=cpvw_prefHandler.getPref(cpvw_Prefs.prefSubsearchBar);
  13. if(!_3){
  14. return;
  15. }
  16. if(!this.toDisplaySearchBar){
  17. return;
  18. }
  19. var _4=cpvw_previewHandler.getPreviewWindow();
  20. var _5=_4.getSearchBarContent();
  21. while(_5.childNodes.length>0){
  22. _5.removeChild(_5.firstChild);
  23. }
  24. var _6=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  25. var _7=_6.split(",");
  26. if(cpvw_contextSitesTreeView.arrCMenuItems==null){
  27. cpvw_contextSitesTreeView.loadContextSites();
  28. }
  29. _4.toggleSearchBar(true,this.selectedText);
  30. var _8=this;
  31. var _9=_5.parentNode.boxObject.x;
  32. var _a=_4.boxObject.width;
  33. var _b=0;
  34. var _c=cpvw_get("cooliris_subSearchMenu");
  35. for(var i=0;i<_7.length;i++){
  36. if(cpvw_contextSitesTreeView.arrCMenuItems[_7[i]]!=null){
  37. if(_7[i]=="cooliris"&&cpvw_jsUtils.hasCooliris()){
  38. var _e=document.createElement("label");
  39. _e.setAttribute("value","Cooliris");
  40. _e.setAttribute("siteId",i);
  41. _e.setAttribute("class","subSearchButton");
  42. _e.addEventListener("click",function(_f){
  43. cpvw_previewHandler.dimPreview.width=950;
  44. cpvw_previewHandler.dimPreview.height=675;
  45. cpvw_previewHandler.pushpin=true;
  46. cpvw_previewHandler.updatePushpinIcon();
  47. cpvw_previewHandler.changeDimensions(cpvw_previewHandler.dimPreview.left,cpvw_previewHandler.dimPreview.top,cpvw_previewHandler.dimPreview.width,cpvw_previewHandler.dimPreview.height,true);
  48. var _10=this;
  49. cpvw_docHandler.popTimer=setTimeout(function(){
  50. var _11=_10.getAttribute("siteId");
  51. _8.showSearchUrl(_11);
  52. cpvw_objStats.sendButtonClickEvents("Cooliris");
  53. },1);
  54. },false);
  55. }else{
  56. if(_7[i]=="cooliris"&&!cpvw_jsUtils.hasCooliris()){
  57. continue;
  58. }else{
  59. var _e=document.createElement("label");
  60. _e.setAttribute("value",cpvw_contextSitesTreeView.arrCMenuItems[_7[i]].label);
  61. _e.setAttribute("siteId",i);
  62. _e.setAttribute("class","subSearchButton");
  63. _e.addEventListener("click",function(evt){
  64. var _13=this.getAttribute("siteId");
  65. _8.showSearchUrl(_13);
  66. var els=_5.getElementsByClassName("subSearchButton");
  67. for(var k=0;k<els.length;k++){
  68. els[k].removeAttribute("selected");
  69. }
  70. this.setAttribute("selected",true);
  71. },false);
  72. }
  73. }
  74. _5.appendChild(_e);
  75. if(_e.boxObject.x>(_9+_a-160)){
  76. _5.removeChild(_e);
  77. var _16=document.createElement("label");
  78. _16.setAttribute("value",">>");
  79. _16.setAttribute("siteId",i);
  80. _16.setAttribute("class","subSearchButton");
  81. _16.addEventListener("click",function(evt){
  82. if(!cpvw_jsUtils.isFF2()){
  83. _c.openPopup(this,"after_end",0,0,false,false);
  84. }else{
  85. _c.showPopup(this,-1,-1,"popup","bottomright","bottomright");
  86. }
  87. },false);
  88. _5.appendChild(_16);
  89. while(_c.childNodes.length>0){
  90. _c.removeChild(_c.firstChild);
  91. }
  92. _b=i;
  93. break;
  94. }
  95. }
  96. }
  97. _c.addEventListener("mouseover",function(){
  98. if(cpvw_docHandler){
  99. conDump("search Context menu ++ "+cpvw_docHandler.hideTimer);
  100. cpvw_docHandler.clearTimer(cpvw_docHandler.hideTimer);
  101. }
  102. },false);
  103. for(i=_b;i<_7.length;i++){
  104. if(cpvw_contextSitesTreeView.arrCMenuItems[_7[i]]!=null){
  105. var _e=document.createElement("menuitem");
  106. _e.setAttribute("label",cpvw_contextSitesTreeView.arrCMenuItems[_7[i]].label);
  107. _e.setAttribute("image",cpvw_contextSitesTreeView.arrCMenuItems[_7[i]].image);
  108. _e.setAttribute("siteId",i);
  109. _e.setAttribute("class","menuitem-iconic");
  110. _e.addEventListener("click",function(evt){
  111. var _19=this.getAttribute("siteId");
  112. _8.showSearchUrl(_19);
  113. },false);
  114. _c.appendChild(_e);
  115. }
  116. }
  117. },doSearch:function(){
  118. var obj=cpvw_jsUtils.decodeJson(cpvw_prefHandler.getPref(cpvw_Prefs.prefQuickSearch));
  119. if(obj){
  120. this.showSearchUrl(obj.lastUsedWebsite);
  121. }
  122. },showSearchUrl:function(_1b){
  123. var _1c=cpvw_previewHandler.getPreviewWindow();
  124. this.selectedText=_1c.getSearchText();
  125. if(cpvw_contextSitesTreeView.arrCMenuItems==null){
  126. cpvw_contextSitesTreeView.loadContextSites();
  127. }
  128. var _1d=cpvw_contextSitesTreeView.getUrl(_1b,this.selectedText);
  129. var obj={"searchPhrase":this.selectedText,"lastUsedWebsite":_1b};
  130. cpvw_prefHandler.setPref(cpvw_Prefs.prefQuickSearch,cpvw_jsUtils.encodeJson(obj));
  131. if(cpvw_docHandler){
  132. var _1f=cpvw_prefHandler.getPref(cpvw_Prefs.prefCMenuItems);
  133. var _20=_1f.split(",");
  134. cpvw_objStats.sendButtonClickEvents("QuickSearchBarItem : "+_20[_1b].toString());
  135. cpvw_docHandler.popTimer=setTimeout(function(){
  136. cpvw_docHandler.showPreview(_1d);
  137. },1);
  138. }
  139. },getSelection:function(){
  140. var _21=document.commandDispatcher.focusedWindow;
  141. this.parentDoc=_21.document;
  142. var _22=_21.getSelection();
  143. var _23=cpvw_jsUtils.trimWhitespace(_22.toString());
  144. this.selectedText=_23;
  145. return _23;
  146. },hideSearchBar:function(_24){
  147. var _25=cpvw_previewHandler.getPreviewWindow();
  148. this.selectedText="";
  149. _25.toggleSearchBar(false,"");
  150. if(_24){
  151. this.toDisplaySearchBar=true;
  152. }
  153. }};
  154.  
  155.